{include file="header.html"}

<div id="rightTop">
    <p>店铺账单管理</p>
    <ul class="subnav">
        <li><span>{$lang.manage}</span></li>
    </ul>
</div>
<div class="mrightTop" style="height: 80px;">
    <div class="fontl">
        <form method="get">
                <input type="hidden" name="app" value="store_bill" />
                <input type="hidden" name="act" value="index" />
                <select class="querySelect" name="status">
                    <option value="">状态</option>
                    {html_options options=$store_bill_status_list selected=$query.status}
                </select>
                <select class="querySelect" name="store_id">
                    <option value="">店铺信息</option>
                    <!--{foreach from=$storeList item=item}-->
                        <option value="{$item.store_id}" <!--{if $item.store_id eq $store_id}-->selected<!--{/if}-->>{$item.store_name}</option>
                    <!--{/foreach}-->
                </select>
                账单周期:<input style="width: 160px;" class="queryInput" type="text" value="{$add_time_from}" id="add_time_from" name="add_time_from"  />
                至:<input class="queryInput" style="width: 160px;" type="text" value="{$add_time_to}" id="add_time_to" name="add_time_to"  />
                账单号：
                <input class="queryInput" style="width:200px;" type="text" name="account_no" value="{$query.account_no}"/>
                <input type="submit" class="formbtn" value="{$lang.query}" onclick="$('[name=act]').val('index');"/>
                <!--{if $filtered}-->
                <a class="formbtn1" href="index.php?app=store_bill">{$lang.cancel_query}</a>
                <!--{/if}-->
        </form>
    </div>
    <div class="fontr">
        {if $res}{include file=page.top.html}{/if}
    </div>
</div>
<div class="tdare">
    <table width="100%" cellspacing="0" class="dataTable">
        <!--{if $res}-->
        <tr class="tatr1">
            <td width="20px" class="firstCell"><input type="checkbox" class="checkall" /></td>
            <td width="30px" class="firstCell"><span fieldname="seller_id">ID</span></td>
            <td width="130px"><span>账单号</span></td>
            <td width="200px"><span>账单周期</span></td>
            <td width="80px;"><span>店铺名称</span></td>
            <td width="80px;"><span>佣金总额</span></td>
            <td width="80px;"><span>订单总额</span></td>
            <td width="150px;"><span>财务确认时间</span></td>
            <td width="150px;"><span>财务打款时间</span></td>
            <td><span>状态</span></td>
            <td>{$lang.handler}</td>
        </tr>
        <!--{/if}-->
        <!--{foreach from=$res item=v}-->
        <tr class="tatr2">
            <td class="firstCell"><input type="checkbox" class="checkitem" value="{$v.id}"/></td>
            <td class="firstCell">{$v.id|escape}</td>
            <td>{$v.account_no}</td>
            <td>{$v.start_time|date:Y-m-d}~~{$v.end_time|date:Y-m-d}</td>
            <td>{$v.store_name}</td>
            <td>{$v.commission_money|price}</td>
            <td>{$v.order_money|price}</td>
            <td>{$v.confirmation_time|date:complete}</td>
            <td>{$v.payment_time|date:Y-m-d H:i:s}</td>
            <td>{$v.status_value}</td>
            <td>
                <!-- {if $v.status eq 1}-->
                    <a  href="javascript:;" class="agree" data-id="{$v.id}">审核通过</a>  |
                <!-- {elseif $v.status eq 2}-->
                    <a href="javascript:;" class="make_money" data-id="{$v.id}">付款</a>  |
                <!-- {elseif $v.status eq 3}-->
                    <a href="javascript:;" class="reason" data-id="{$v.id}">无</a>   |
                <!--{/if}-->
                    <a href="javascript:;" class="detail" data-id="{$v.id}">查看账单信息</a>  |
                    <a href="index.php?app=store_bill&act=excel&id={$v.id}" class="excel" data-id="{$v.id}">导出</a>

            </td>
        </tr>
        <!--{foreachelse}-->
        <tr class="no_data">
            <td colspan="7">{$lang.no_data}</td>
        </tr>
        <!--{/foreach}-->
    </table>
    <!--{if $res}-->
        <div id="dataFuncs">
            <div id="batchAction" class="left paddingT15">
                <input class="formbtn1 batchButton" type="button" value="审核通过" name="id" uri="index.php?app=store_bill&act=operations&ret_page={$page_info.curr_page}" presubmit="confirm('您确定审核通过么？')" />
            </div>
            <div class="pageLinks">
                {if $res}{include file=page.bottom.html}{/if}
            </div>
        </div>
    <!--{/if}-->
    <div class="clear"></div>
</div>
{include file="footer.html"}
<script src="//cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/layer/2.3/layer.js"></script>
<script src="templates/js/laydate/laydate.js"></script>
<script type="text/javascript">
    //时间选择器
    laydate.render({
        elem: '#add_time_from'
        ,type: 'datetime'
    });

    //时间选择器
    laydate.render({
        elem: '#add_time_to'
        ,type: 'datetime'
    });
</script>
<script>
    //ajax请求地址  操作是否同意申请接口
    var url = "index.php?app=store_bill&act=operation";
    //同意申请
    $(".agree").click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('确认审核通过这个申请么？', {
            btn: ['是','否'] //按钮
        }, function(){
            var index = layer.load(0, {
                shade: false
            }); //0代表加载
            $.post(url,{
                id:id,
                status:2
            },function(data){
                layer.closeAll('loading');
                var res = JSON.parse(data);
                layer.msg(res.msg,function(){
                    window.location.reload();
                });
            })
        })
    })

    //打款
    $(".make_money").click(function(){
        var id = $(this).attr('data-id');
        var url = "index.php?app=store_bill&act=makeMoney";
        layer.confirm('确认要打款么？', {
            btn: ['是','否'] //按钮
        }, function(){
            var index = layer.load(0, {
                shade: false
            }); //0代表加载
            $.post(url,{
                id:id,
                status:4
            },function(data){
                layer.closeAll('loading');
                var res = JSON.parse(data);
                layer.msg(res.msg,function(){
                    window.location.reload();
                });
            })
        })
    })
    //查看账单详情
    $(".detail").click(function(){
        var url = "index.php?app=store_bill&act=detail";
        var id = $(this).attr('data-id');
        var index = layer.load(0, {
            shade: false
        }); //0代表加载
        $.post(url,{
            id:id
        },function(data){
            layer.closeAll('loading');
            var res = JSON.parse(data);

            var str = ' <table width="100%" cellspacing="0" class="dataTable">\n' +
                '        <tr class="tatr1">\n' +
                '            <td><span>订单号</span></td>\n' +
                '            <td><span>订单收款日期</span></td>\n' +
                '            <td><span>产品编码</span></td>\n' +
                '            <td><span>产品名称</span></td>\n' +
                '            <td><span>sku</span></td>\n' +
                '            <td><span>数量</span></td>\n' +
                '            <td><span>产品单价</span></td>\n' +
                '            <td><span>总金额(不含税不运费)</span></td>\n' +
                '            <td><span>订单成交日期</span></td>\n' +
                '            <td><span>服务费%</span></td>\n' +
                '            <td><span>服务费</span></td>\n' +
                '            <td><span>销售方式</span></td>\n' +
                '            <td><span>业务员</span></td>\n' +
                '            <td><span>业务员代码</span></td>\n' +
                '        </tr>';
            if(res.code == 1){
                $.each(res.data,function(index,item){
                    str +=  '<tr class="tatr2">\n' +
                    '            <td>'+item.data.order_sn+'</td>\n' +
                    '            <td>'+item.order_pay_time_value+'</td>\n' +
                    '            <td>'+item.data.goods_id+'</td>\n' +
                    '            <td>'+item.data.goods_name+'</td>\n' +
                    '            <td>'+item.data.sku+'</td>\n' +
                    '            <td>'+item.data.num+'</td>\n' +
                    '            <td>'+item.data.price+'</td>\n' +
                    '            <td>'+item.data.price_amount+'</td>\n' +
                    '            <td>'+item.order_finish_time_value+'</td>\n' +
                    '            <td>'+item.commission_proportion_value+'%</td>\n' +
                    '            <td>'+item.sign +''+item.data.commission+'</td>\n' +
                    '            <td>'+item.data.stock_style+'</td>\n' +
                    '            <td>'+item.store_name+'</td>\n' +
                    '            <td>'+item.serial_number+'</td>\n' +
                    '        </tr>';
                })
                str += '</table>';
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['100%','80%'], //宽高
                    content: str
                });
            }else{
                layer.msg(res.msg);
            }
        })
    })
</script>


